define([ 'backbone', 'underscore', 'jquery', 'jqueryui'

], function(Backbone, _, $

) {

	return Backbone.View.extend({

		events : {
			"slidechange" : "updateVal"
		},
		updateVal : function() {
			this.model.set({
				size : $(this.el).slider("value")
			});
		},

		initialize : function() {

			$(this.el).slider();

			// bindAll() works like to set a jQuery proxy()
			// it means all methods exposed as arguments of the "bindAll()"
			// always receives
			// the first argument as context!
			_.bindAll(this, 'updateValue');

			// bind the model's change event to the view's render() method.
			// thanks to _.bindAll() before "this.render" receive the view
			// itself as execution context
			this.model.bind("change:slidervalue", this.updateValue);

		},

		updateValue : function() {

			console.log('ValueView.updateValue');

		}

	});

});